import { MockMethod } from "vite-plugin-mock"

export default [
  {
    url: "/dev-api/system/user/search",
    timeout: 2000,
    method: "post",
    response: () => {
      return {
        "code": 20000,
        "message": "查询成功",
        "data": {
          "total": "@integer(10, 50)", // 总记录数
          "records|20": [{ //生成20条数据
            "id|+1": '1', //初始值1开始，每条+1
            "username": "@word(10)", // 用户帐号
            "password|6": /\d/, // 密码，均为隐藏*号
            "nickName": "@cname", // 用户昵称
            "mobile": /1\d{10}/, //正则表达式
            "roleIds|1": [ // 不要使用 [1, 2, 3] 因为这样返回的是数字1，而不是返回数组[1]
              [1],
              [1, 2],
              [3]
            ], // 拥有角色ids
            "email": "@email()",
            "imageUrl": "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif?imageView2/1/w/80/h/80",
            "remark": "@ctitle",
            "accountNonExpired|1": true, // 帐号是否过期(true 未过期，false已过期) 生成 true 或 false 概率都是 1/2
            "accountNonLocked|1": true, // 帐户是否被锁定(true 未锁定，false已锁定)
            "credentialsNonExpired|1": true, // 密码是否过期(true  未过期，false已过期)
            "createTime": "@datetime",
            "updateTime": "@datetime"
          }]
        }
      }
    }
  },
  {
    url: "/dev-api/system/user/:id",
    timeout: 2000,
    method: "delete",
    response: () => {
      return {
        "code": 20000,
        "message": "删除成功",
        "data": true
      }
    }
  },
  {
    url: "/dev-api/system/user",
    timeout: 2000,
    method: "post",
    response: () => {
      return {
        "code": 20000,
        "message": "增加成功",
        "data": true
      }
    }
  },
  {
    url: "/dev-api/system/user",
    timeout: 2000,
    method: "put",
    response: () => {
      return {
        "code": 20000,
        "message": "更新成功",
        "data": true
      }
    }
  },
  {
    url: "/dev-api/system/user/exist",
    timeout: 2000,
    method: "get",
    response: () => {
      return {
        "code": 20000,
        "message": "不存在",
        "data": false // true已存在，false不存在，
      }
    }
  },
  {
    url: "/dev-api/system/user/password",
    timeout: 2000,
    method: "put",
    response: () => {
      return {
        "code": 20000,
        "message": "修改成功",
        "data": true
      }
    }
  },
] as MockMethod[]